package com.yunhe.task.controller.data;

import com.yunhe.common.constant.AuthorityConsts;
import com.yunhe.common.model.ResultObject;
import com.yunhe.task.task.DataMonitorTask;
import com.yunhe.task.task.ElectricityTask;
import com.yunhe.task.task.VirtualPointCalculateTask;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "MeasTaskController",description = "量测任务", tags = {"Task_MeasTask"})
@RestController
@RequestMapping("/measTask")
public class MeasTaskController {

    @Autowired
    private DataMonitorTask dataMonitorTask;
    @Autowired
    private ElectricityTask electricityTask;
    @Autowired
    private VirtualPointCalculateTask virtualPointCalculateTask;
//    @Autowired
//    private IPCOutOfContactTask ipcOutOfContactTask;

    @ApiOperation("执行15mim切数据任务")
    @RequestMapping(value = "/dataMonitor15mTask", method = RequestMethod.POST)
    public ResponseEntity<ResultObject> runDataMonitor15mTask() {
        dataMonitorTask.monitor15();
        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
    }

    @ApiOperation("执行每日电量统计任务")
    @RequestMapping(value = "/electricityTask", method = RequestMethod.POST)
    public ResponseEntity<ResultObject> runElectricityTask() {
        electricityTask.calculateDay(AuthorityConsts.FIRM_CODE.TB.value());
        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
    }

    @ApiOperation("执行每月电量统计任务")
    @RequestMapping(value = "/electricityMonthTask", method = RequestMethod.POST)
    public ResponseEntity<ResultObject> runElectricityMonthTask() {
        electricityTask.calculateMonth(AuthorityConsts.FIRM_CODE.TB.value());
        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
    }

    @ApiOperation("执行虚拟点号计算任务")
    @RequestMapping(value = "/virtualPointCalculateTask", method = RequestMethod.POST)
    public ResponseEntity<ResultObject> runVirtualPointCalculateTask() {
        virtualPointCalculateTask.calculate();
        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
    }

//    @ApiOperation("执行1mim切数据任务")
//    @RequestMapping(value = "/dataMonitor1mTask", method = RequestMethod.POST)
//    public ResponseEntity<ResultObject> runDataMonitor1mTask() {
//        dataMonitorTask.monitor1();
//        return new ResponseEntity<>(new ResultObject(null), HttpStatus.OK);
//    }

//    @ApiOperation("执行监控工控机失联任务")
//    @RequestMapping(value = "/ipcOutOfContactTask", method = RequestMethod.POST)
//    public ResponseEntity<ResultObject> runIPCOutOfContactTask() {
//        ipcOutOfContactTask.task();
//        return new ResponseEntity<>(new ResultObject(null), HttpStatus.OK);
//    }
}
